<!--
	Author: W3layouts
	Author URL: http://w3layouts.com
-->
<!DOCTYPE html>
<html lang = "zh-cmn-Hans" >

<!-- Head -->

<head >
	
	<title >暴富云盘</title >
	
	<!-- Meta-Tags -->
	<meta charset = "UTF-8" >
	<meta content = "width=device-width, initial-scale=1.0" name = "viewport" >
	<meta content = "ie=edge" http-equiv = "X-UA-Compatible" >
	
	<!-- style CSS -->
	<link href = "css/style.css" media = "all" rel = "stylesheet" type = "text/css" >
	<link href = "css/register.css" media = "all" rel = "stylesheet" type = "text/css" >
	<!-- google fonts -->
	<link href = "https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap"
	      rel = "stylesheet" >
	<script src = "js/jquery.min.js" ></script >
	<script src = "bootstrap-3.3.7-dist/js/bootstrap.min.js" ></script >
	<script src = "js/http.js" ></script >
</head >
<!-- //Head -->

<!-- Body -->

<body >

<section class = "main" >
	<div class = "logo text-center" >
		<h1 ><a href = "https://www.gzbrain.cn/" > 暴富云盘</a ></h1 >
		<h1 ><a href = "https://www.gzbrain.cn/" > 注册</a ></h1 >
	</div >
	<div class = "text-center" >
		<img alt = "" class = "img-responsive" src = "img/admin.png" >
		<form action = "#" method = "post" >
			<div class = "wthree-field" >
				<label >
					<input name = "username" placeholder = "用户名" type = "text" value = "" >
				</label >
			</div >
			<div class = "wthree-field" >
				<label >
					<input name = "password" placeholder = "密码" type = "Password" >
				</label >
			</div >
			<div class = "wthree-field" >
				<label >
					<input name = "email" placeholder = "电子邮箱" type = "text" >
				</label >
			</div >
			<div class = "wthree-field" >
				<input class = "btn" onclick = "httpRegister()" type = "button"
				       value = "注册" >
			</div >
			<div class = "login-bottom" >
				<a class = "" href = "login.html" >已有账号，前往登录</a >
			</div >
		</form >
	</div >
	<div class = "copyright" >
		<p >©使用暴富网盘你每天都幸福 <a
				href = "http://www.chinacharityfederation.org/" target = "_blank" >加油把骚年</a ></p >
	</div >
</section >

</body >
<!-- //Body -->

</html >

<script >
	function httpRegister() {
		let usernameVal = $("[name='username']").val();
		let passwordVal = $("[name='password']").val();
		let emailVal = $("[name='email']").val();

		let usernameCheck=new RegExp("^[a-zA-Z][a-zA-Z0-9_]{4,15}$");
		let passwordCheck=new RegExp("^[a-zA-Z]\\w{5,17}$");
		let emailCheck=new RegExp("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
		if(!usernameCheck.test(usernameVal)){
			alert("用户名应字母开头，允许5-16字节，允许字母数字下划线");
			return;
		}

		if(!passwordCheck.test(passwordVal)){
			alert("密码格式为:字母开头，长度在6~18之间，只能包含字母、数字和下划线");
			return;
		}

		if(!emailCheck.test(emailVal)){
			alert("邮箱格式不正确，请重新输入");
			return;
		}

		let paramUserQO = JSON.stringify({
			id: null,
			username: usernameVal,
			password: passwordVal,
			email: emailVal
		});
		httpPostWithParams("/user/register", paramUserQO, function(resp) {
			alert(resp.message)
			if(resp.status == 1) {
				location.href = "login.html"
			}
		});
	}
</script >